package Tracer;

/**
 * ClassName : RTCanvas. This is a canvas used to draw the result bitmap. To
 * generate the result bitmap, you have to traverse every pixel in this canvas
 * 
 * @version 1.0 Oct 6th 2009
 * @author LU LIU
 */
public class RTCanvas {

	/**
	 * the upper left corner of canvas
	 */
	private RTVector cCornerUL;
	/**
	 * the right direction from corner
	 */
	private RTVector cRightD;
	/**
	 * the down direction from corner
	 */
	private RTVector cDownD;
	/**
	 * the width of canvas
	 */
	private double cWidth;
	/**
	 * the height of canvas
	 */
	private double cHeight;
	/**
	 * the zoom of canvas
	 */
	private double cZoom;
	/**
	 * the pixel number of x
	 */
	private int cXpix;
	/**
	 * the pixel number of y
	 */
	private int cYpix;
	/**
	 * the resolution of x
	 */
	private double cRx;
	/**
	 * the resolution of y
	 */
	private double cRy;
	/**
	 * the reflection depth , 5 by default
	 */
	private int reflectionDepth = 5;
	/**
	 * the flag value for Shadowing and reflection
	 */
	private boolean isShadowingReflection = true;
	/**
	 * the flag value for calculate trace time
	 */
	private boolean isCalTraceTime = false;

	/**
	 * Class Constructor for RTCanvas
	 */
	public RTCanvas() {
		cCornerUL = new RTVector();
		cRightD = new RTVector();
		cDownD = new RTVector();
	}

	/**
	 * Getter method of reflectionDepth
	 * 
	 * @return the reflectionDepth
	 */
	public final int getReflectionDepth() {
		return reflectionDepth;
	}

	/**
	 * Setter method of reflectionDepth
	 * 
	 * @param depthValue
	 *            the reflection depth to set
	 */
	public final void setReflectionDepth(final int depthValue) {
		if (depthValue <= 0) {
			this.reflectionDepth = 1;
		} else {
			this.reflectionDepth = depthValue;
		}
	}

	/**
	 * Getter method of isShadowingReflection
	 * 
	 * @return the isShadowingReflection
	 */
	public final boolean getIsShadowingReflection() {
		return isShadowingReflection;
	}

	/**
	 * Setter method of isShadowingReflection
	 * 
	 * @param boolValue
	 *            the boolean value to set
	 */
	public final void setIsShadowingReflection(final boolean boolValue) {
		this.isShadowingReflection = boolValue;
	}

	/**
	 * Getter method of coordination for Upper Left corner
	 * 
	 * @return the ccornerUL
	 */
	public final RTVector getCornerUL() {
		return cCornerUL;
	}

	/**
	 * Setter method of coordination for Upper Left corner
	 * 
	 * @param ccornerul
	 *            the ccornerUL to set
	 */
	public final void setCornerUL(final RTVector ccornerul) {
		cCornerUL = ccornerul;
	}

	/**
	 * Getter method of direction vector for Right
	 * 
	 * @return the _rightD
	 */
	public final RTVector getRightD() {
		return cRightD;
	}

	/**
	 * Setter method of direction vector for Right
	 * 
	 * @param crightd
	 *            the _rightD to set
	 */
	public final void setRightD(final RTVector crightd) {
		cRightD = crightd;
	}

	/**
	 * Getter method of direction vector for Down
	 * 
	 * @return the _downD
	 */
	public final RTVector getDownD() {
		return cDownD;
	}

	/**
	 * Setter method of direction vector for Down
	 * 
	 * @param cdownd
	 *            the _downD to set
	 */
	public final void setDownD(final RTVector cdownd) {
		cDownD = cdownd;
	}

	/**
	 * Getter method of width
	 * 
	 * @return the _width
	 */
	public final double getWidth() {
		return cWidth;
	}

	/**
	 * Setter method of width
	 * 
	 * @param width
	 *            the _width to set
	 */
	public final void setWidth(final double width) {
		if (width <= 0) {
			this.cWidth = 2d;
		} else {
			this.cWidth = width;
		}
	}

	/**
	 * Getter method of height
	 * 
	 * @return the _height
	 */
	public final double getHeight() {
		return cHeight;
	}

	/**
	 * Setter method of height
	 * 
	 * @param height
	 *            the _height to set
	 */
	public final void setHeight(final double height) {
		if (height <= 0) {
			this.cHeight = 2d;
		} else {
			this.cHeight = height;
		}
	}

	/**
	 * Getter method of zoom value
	 * 
	 * @return the _zoom
	 */
	public final double getZoom() {
		return cZoom;
	}

	/**
	 * Setter method of zoom value
	 * 
	 * @param zoom
	 *            the zoom to set
	 */
	public final void setZoom(final double zoom) {
		this.cZoom = zoom;
	}

	/**
	 * Getter method of pixels for x direction
	 * 
	 * @return the _xpix
	 */
	public final int getXpix() {
		return cXpix;
	}

	/**
	 * Setter method of pixels for x direction
	 * 
	 * @param xpix
	 *            the _xpix to set
	 */
	public final void setXpix(final int xpix) {
		if (xpix <= 0) {
			this.cXpix = 240;
		} else {
			this.cXpix = xpix;
		}
	}

	/**
	 * Getter method of pixels for y direction
	 * 
	 * @return the _ypix
	 */
	public final int getYpix() {
		return cYpix;
	}

	/**
	 * Setter method of pixels for x direction
	 * 
	 * @param ypix
	 *            the _ypix to set
	 */
	public final void setYpix(final int ypix) {
		if (ypix <= 0) {
			this.cYpix = 240;
		} else {
			this.cYpix = ypix;
		}
	}

	/**
	 * Getter method of resolution for x direction
	 * 
	 * @return the _Rx
	 */
	public final double getRx() {
		cRx = cWidth / cXpix;
		return cRx;
	}

	/**
	 * GetterGetter method of resolution for y direction
	 * 
	 * @return the cRy
	 */
	public final double getRy() {
		cRy = cHeight / cYpix;
		return cRy;
	}

	/**
	 * Getter method of isCalTraceTime
	 * 
	 * @return the isCalTraceTime
	 */
	public final boolean getIsCalTraceTime() {
		return isCalTraceTime;
	}

	/**
	 * Setter method of isCalTraceTime
	 * 
	 * @param boolValue
	 *            the boolean value to set
	 */
	public final void setIsCalTraceTime(final boolean boolValue) {
		this.isCalTraceTime = boolValue;
	}
}
